package com.base.andlangui.view.glsurface

import android.content.Context
import android.opengl.GLSurfaceView
import android.util.AttributeSet
import android.widget.LinearLayout
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import com.base.andlangcore.util.LogUtils

/**
 * 自定义GLSurfaceView 监听Activity生命周期
 */
class LangSurfaceView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null
) : GLSurfaceView(context, attrs),LifecycleEventObserver {
    init {

    }

    //Activity生命周期
    override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
        when(event) {
            Lifecycle.Event.ON_PAUSE -> {
                LogUtils.d("ON_PAUSE")
                onPause()
            }
            Lifecycle.Event.ON_RESUME -> {
                LogUtils.d("ON_RESUME")
                onResume()
            }
        }
    }
}